package com.redside.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * @author PCHAPMAN
 * 
 */
@Entity
@Table(name = "email")
public class Email extends BaseObject implements java.io.Serializable {

    private static final long serialVersionUID = 4768317119175886220L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "email_id")
    private Long id;
    
    @Column(name="county_id", length = 6)
    private String countyId;
    
    @ManyToOne
    @JoinColumn(name = "correspondence_id")
    private Correspondence correspondence;
    
    @Column(name="email_type_id")
    private Long emailTypeId;
    
    @Column(name="first_name", length=50)
    private String firstName;
    
    @Column(name="last_name", length=50)
    private String lastName;
    
    @Column(name="email_to", length=75)
    private String emailTo;
    
    @Column(name="email_cc", length=75)
    private String emailCc;
    
    @Column(name="email_from", length=75)
    private String emailFrom;
    
    @Column(name="subject", length=250)
    private String subject;

    public Email() {
    }

    /**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the countyId
	 */
	public String getCountyId() {
		return countyId;
	}

	/**
	 * @param countyId the countyId to set
	 */
	public void setCountyId(String countyId) {
		this.countyId = countyId;
	}

	/**
	 * @return the correspondence
	 */
	public Correspondence getCorrespondence() {
		return correspondence;
	}

	/**
	 * @param correspondence the correspondence to set
	 */
	public void setCorrespondence(Correspondence correspondence) {
		this.correspondence = correspondence;
	}

	/**
     * @return the emailTypeId
     */
    public Long getEmailTypeId() {
        return emailTypeId;
    }

    /**
     * @param emailTypeId the emailTypeId to set
     */
    public void setEmailTypeId(Long emailTypeId) {
        this.emailTypeId = emailTypeId;
    }

    /**
     * @return the firstName
     */
    public String getFirstName() {
        return firstName;
    }

    /**
     * @param firstName the firstName to set
     */
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    /**
     * @return the lastName
     */
    public String getLastName() {
        return lastName;
    }

    /**
     * @param lastName the lastName to set
     */
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    /**
     * @return the emailTo
     */
    public String getEmailTo() {
        return emailTo;
    }

    /**
     * @param emailTo the emailTo to set
     */
    public void setEmailTo(String emailTo) {
        this.emailTo = emailTo;
    }

    /**
     * @return the emailCc
     */
    public String getEmailCc() {
        return emailCc;
    }

    /**
     * @param emailCc the emailCc to set
     */
    public void setEmailCc(String emailCc) {
        this.emailCc = emailCc;
    }

    /**
     * @return the emailFrom
     */
    public String getEmailFrom() {
        return emailFrom;
    }

    /**
     * @param emailFrom the emailFrom to set
     */
    public void setEmailFrom(String emailFrom) {
        this.emailFrom = emailFrom;
    }

    /**
     * @return the subject
     */
    public String getSubject() {
        return subject;
    }

    /**
     * @param subject the subject to set
     */
    public void setSubject(String subject) {
        this.subject = subject;
    }

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof Email)) {
			return false;
		}
		Email rhs = (Email) object;
		return new EqualsBuilder().append(
				this.lastName, rhs.lastName).append(this.id, rhs.id)
				.append(this.emailCc, rhs.emailCc).append(this.subject,
						rhs.subject).append(this.emailTo, rhs.emailTo).append(
						this.emailFrom, rhs.emailFrom).append(this.firstName,
						rhs.firstName).append(this.countyId, rhs.countyId)
				.append(this.emailTypeId, rhs.emailTypeId).isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-1491721535, -2005693311).append(this.lastName)
				.append(this.emailCc).append(this.subject).append(this.emailTo)
				.append(this.emailFrom).append(this.firstName).append(
						this.countyId).append(this.emailTypeId).toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this).append("emailFrom", this.emailFrom)
				.append("emailId", this.id)
				.append("emailCc", this.emailCc).append("countyId",
						this.countyId).append("subject", this.subject).append(
						"emailTypeId", this.emailTypeId).append("emailTo",
						this.emailTo).append("firstName", this.firstName)
				.append("lastName", this.lastName).toString();
	}

}
